using Sedge.Core.Configuration;
using Sedge.Core.Execution;
using Sedge.Core.Execution.ReportElements;
using Sedge.Core.Globalization;
using Sedge.Core.Utils;

namespace Sedge.UI.ViewModel
{
	public class GeneralizedErrorViewModel
	{
		private readonly Suite _suite;
		private readonly Options _options;

		public GeneralizedErrorViewModel(Suite suite, Options options)
		{
			_suite = suite;
			_options = options;

			if (_suite.Applications.Count == 1)
			{
				_suite.SelectApplication(_suite.Applications[0].Caption);
			}
		}

		public void StoreData(string[] description)
		{
			ReportTable reportTable = new ReportTable(_suite);
			if (_suite.SelectedApplication != null)
			{
				reportTable.AddRow(Locale.TemplateStrings.ReportApplication, _suite.SelectedApplication.Caption);
			}
			reportTable.AddRow(Locale.TemplateStrings.ReportDescription, HtmlHelper.ArrayToBreakedString(description));

			_suite.TempData[TempDataKeys.ReportDetailsKey] = reportTable;
		}
	}
}